package com.info33.platform.system.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.info33.platform.system.dao.SysNewsDao;
import com.info33.platform.system.entity.SysNews;
import com.info33.platform.system.service.SysNewsService;
import com.info33.platform.common.mvc.vo.Result;

@Service("SysNewsService")
public class SysNewsServiceImpl extends ServiceImpl<SysNewsDao, SysNews> implements SysNewsService {
	@Autowired
	SysNewsDao sysNewsDao;

	@Override
	public Result<?> getNews(Long tenantId) {
		Map<String,Object>map=new HashMap<>();
		Date date = new Date();
		SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		String now = fmt.format(date);
		// 获取在有效开始时间和结束时间的新闻信息，start_time<=当前时间<=end_time
		map.put("tenantId",tenantId);
		map.put("now",now);
		List<SysNews> news = sysNewsDao.getnewsList(map);
		return Result.ok(news);
	}

}
